﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DB_NH.DB_Map.ZJCQ
{
    using NHibernate;
    using NHibernate.Mapping.ByCode;
    using NHibernate.Mapping.ByCode.Conformist;

    using DB_NH.DB_Model.ZJCQ;

    class ZJ_extract_map : EntityMapping<ZJ_extract>
    {
        public ZJ_extract_map()
        {
            Property(x => x.extract_date, map =>
            {
                map.Column(ZJ_extract.Columns.extract_date);
            });

            Property(x => x.title, map =>
            {
                map.Column(ZJ_extract.Columns.title);
                map.Length(400);
            });

            //与抽取用户关联纪录
            ManyToOne(x => x.user, map =>
            {
                map.Column(ZJ_extract.Columns.user_id);
                map.NotNullable(false);
            });

            //与抽取详细记录关联
            Bag(x => x.details,
                map => map.Key(km => km.Column(ZJ_extract_detail.Columns.extract_id)),
                act => act.OneToMany());

            //关联项目与抽取关联记录
            Bag(x => x.zj_extract_projects,
                map => { },
                act => act.ManyToMany());

            Table(ZJ_extract.TableName);
        }
    }
}
